<?php
namespace app\index\controller\system;

use app\index\controller\Base;
use think\Cache;
class config extends Base
{
    public  function set(){

        if (request()->instance()->isPost()) {
            $post = request()->instance()->param();
            $key_item=[];
            $items_config=[];
            foreach($post as $key=>$value){
                $key_item[]=$key;
                $tmp_data["ckey"]=$key;
                $tmp_data["cvalue"]=$value;
                $items_config[]=$tmp_data;
            }
          if(!empty($key_item)){
              model("Sysconfig")->where(["ckey"=>array("in",$key_item)])->delete();
          }
        $result=  model("Sysconfig")->saveAll($items_config);
        if(empty($result)){
            $this->error("设置失败");
        }
        $this->success("设置成功");
        }
       $Sysconfig= model("Sysconfig")->select()->toArray();
         $data["Sysconfig"]=  array_column( $Sysconfig,"cvalue","ckey");
        $this->assign($data);
        return view();
    }
}